<?php
    
    $userName = $_GET['userName'];
    $passWord = $_GET['passWord'];
	
	if ($userName == "") {
	    $userName = $_POST['userName'];
	    $passWord = $_POST['passWord'];
	}
	
    
    $connect = mysql_connect('localhost','root','1234');
    if($connect) {
        mysql_select_db('user_info'); //打开数据库
        $sql = "SELECT passWord from userinfo where userName = '".$userName."'";
        $result = mysql_query($sql,$connect);
		$row = mysql_fetch_assoc($result);
 		if (var_dump($row)) {
 			$sqlpw = $row['passWord'];
 			$sqlpwMD5 = strtoupper(MD5($sqlpw));
 			if($sqlpwMD5 == $passWord) {
 				echo "{\"code\":\"0\",\"msg\":\"登录成功\"}";
 			} else {
 				echo "{\"code\":\"-1\",\"msg\":\"密码错误\"}";
 			}
 		} else {
 			echo "{\"code\":\"-1\",\"msg\":\"用户名不存在\"}";
 		}
    } else {
        echo "{\"code\":\"-1\",\"msg\":\"数据库连接失败\"}";
    }
    mysql_close($connect);
?>